Most of us are familiar with comparing
the average values between two groups.
For example, the average teaching evaluation square group
four male instructors compared
with that of female instructors,
and the groups are two,
and we know that such comparisons
are made using the t-test.
But what if you're dealing with more than two groups?
What if there are three, four or more groups?
In that particular case,
we would use ANOVA or analysis of variance,
where our intent or goal is to compare
the means of more than two groups.
So in order to accomplish this,
we return back to our teaching evaluation data.
In that particular case,
we have a variable called age,
where the age of the instructor
is recorded in a number of years.
But we will discretize this age variable,
that is, we will create three groups.
So instructors who are 40 years and
younger we put them in one group,
those between 40 and 56.5 years of age,
they are in another group,
and those who are 57 years and older,
you put them in the third group.
So you have younger instructors,
middle-age instructors and
rather slightly older instructors,
and the number of observations,
taught by each group, is reported under
N. What we also have here
is the teaching evaluation score for each group,
which is not deferring much.
It's pretty much four for
each group and for the older professors is
slightly less at 3.9 in
that respective standard deviations of it.
So we have three groups and let's see what
we are interested in is to determine
if these three averages for
the three respective age categories
are statistically the same or they are different,
so we use the one-way analysis of variance or ANOVA,
and using the ANOVA we use
the F-distribution to compare
the mean values for more than two groups.
Our null hypothesis is that samples in
all groups are drawn from the same populations
with the same mean values.
We fail to reject the null hypothesis
if the P-value or the significance for
the F-test is greater than 0.05
and we then infer equal means.
Let's say we are interested in determining if
the beauty score for instructors differs by age.
We have three groups, younger,
middle aged, and older professors.
We have the summary statistics for
the standardized beauty scores.
We see that there is a difference as the age goes up,
the average value for the beauty score goes down.
So let's run an ANOVA to see
if the differences are statistically significant.
Our null hypothesis will be,
"Mean beauty scores for instructors don't differ with
age," and the alternative hypothesis will be,
"At least one of the means is different."
First, this variable does not exist in our data.
We will need to group or been the continuous age data
using the dot loc function in Pandas.
Then use the F underscore one wave function in
the Scipy Stats Library to perform the ANOVA test.
We will then print out the F statistics and the P-value.
What we can see is that the P-value is
4.32 times ten raised to the power of negative eight,
and that is less than 0.05.
We will reject the null hypothesis as there is
significant evidence that at
least one of the means differ.
If I do the same tests for
the teaching evaluation scores
that we observe for the three groups,
and we run ANOVA on these three mean values.
We find out that the P-value is 0.295,
which is greater than 0.05.
We will fail to reject the null and infer equal means.
That is, that the three means
are not statistically different.
Here we have the Analysis of
Variants performed on two samples.
One is the beauty score.
We notice that the difference in means for beauty scores
between the three groups is
based on the significance value.
This leads us to conclude that
at least one mean is different
and we reject the null hypothesis
that states equal means.
Here, because the P-value for teaching
evaluation scores between the three groups
is greater than 0.05,
we fail to reject the null hypothesis.
We believe that these three means
are statistically equal.